package config

import "strconv"

type Mysql struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Config   string `yaml:"config"` // 高级配置,如charset
	Db       string `yaml:"db"`
	Usr      string `yaml:"user"`
	Password string `yaml:"password"`
	LogLevel string `yaml:"log-level"` // debug等级，debug输出全部sql，dev，release
}

func (m Mysql) Dsn() string {
	return m.Usr + ":" + m.Password + `@tcp(` + m.Host + ":" + strconv.Itoa(m.Port) + ")/" + m.Db + "?" + m.Config
}
